using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace DataModels.Models
{
    [Table("Queries")]
    public partial class Query : ModelBase
    {
        private string _Name;
        private string _InternalName;
        private string _Description;
        private string _Definition;
        private string _More;

        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        [StringLength(1000)]
        [Required]
        public string Name 
        {
            get { return _Name; }
            set
            {
                _Name = value;
                OnPropertyChanged("Name");
            }
        }

        [StringLength(1000)]
        [Required]
        [Index(IsUnique = true)]
        public string InternalName 
        {
            get { return _InternalName; }
            set
            {
                _InternalName = value;
                OnPropertyChanged("InternalName");
            }
        }

        [StringLength(1000)]
        public string Description 
        {
            get { return _Description; }
            set
            {
                _Description = value;
                OnPropertyChanged("Description");
            }
        }

        [Required]
        public string Definition 
        {
            get { return _Definition; }
            set
            {
                _Definition = value;
                OnPropertyChanged("Definition");
            }
        }

        /// <summary>
        /// This could be anything...
        /// </summary>
        [StringLength(1000)]
        public string More 
        {
            get { return _More; }
            set
            {
                _More = value;
                OnPropertyChanged("More");
            }
        }

        public int QueryTypeId { get; set; }

        /// <summary>
        /// Is this query deleted or still in use
        /// </summary>
        public bool Deleted { get; set; }

        public DateTime CreateDate { get; set; }
        public Nullable<int> CreatedByUserId { get; set; }
        public Nullable<System.DateTime> UpdateDate { get; set; }
        public Nullable<int> UpdatedByUserId { get; set; }
        public Nullable<System.DateTime> DeleteDate { get; set; }
        public Nullable<int> DeletedByUserId { get; set; }

        /// <summary>
        /// Determines whether this query should be transformed into the table
        /// </summary>
        public bool CreateTable { get; set; }

        [ForeignKey("QueryTypeId")]
        public virtual QueryType QueryType { get; set; }

        [ForeignKey("CreatedByUserId")]
        public virtual User CreatedByUser { get; set; }

        [ForeignKey("UpdatedByUserId")]
        public virtual User UpdatedByUser { get; set; }

        [ForeignKey("DeletedByUserId")]
        public virtual User DeletedByUser { get; set; }

        public virtual List<QueryCategory> QueryCategories { get; set; }
        public virtual List<QueryParameter> QueryParameters { get; set; }
    }
}
